﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Microsoft.Popfly.GameCreator.GameEngine.Events
{
    public class EventCheckerFactory
    {
        public static IEventChecker CreateEventChecker(Game game, BehaviorOwner owner, EventListener thisListener, Data.EventInfo eventInfo)
        {
            switch (eventInfo.Type)
            {
                case "timer" :
                case "Timer" :
                    return TimerEventCheckerFactory.CreateTimerEventChecker(game, (Data.TimerEventInfo) eventInfo);
                case "keys" :
                    return KeyEventCheckerFactory.CreateKeyEventChecker(game, (Data.KeyEventInfo)eventInfo);
                case "" : // This means they didn't set anything so it should default to load
                case "Load" :
                    return new LoadEventChecker(game, owner, thisListener);
                case "StateChange" :
                    return new StateChangeEventChecker(owner, ((Data.StateChangeEventInfo)eventInfo).State);
                case "SceneLeave" :
                    return new VisualSceneLeaveChecker(owner, (Data.SceneEventInfo)eventInfo);
                case "SceneEnter" :
                    return new VisualSceneEnterChecker(owner, (Data.SceneEventInfo)eventInfo);
                case "ViewportEnter" :
                    return new VisualViewportEnterChecker(owner, (Data.ViewportEventInfo)eventInfo);
                case "ViewportLeave" :
                    return new VisualViewportLeaveChecker(owner, (Data.ViewportEventInfo)eventInfo);
                case "collision" :
                    return new CollisionEndChecker(owner, eventInfo);
                case "mouse":
                    return MouseEventCheckerFactory.CreateMouseEventChecker(game, owner, eventInfo);
                case "PropertyChange" :
                    return PropertyEventFactory.CreatePropertyEventChecker(game, owner, eventInfo);
                default :
                    throw new NotImplementedException(
                        Utils.ErrorMessagePrefix +
                        "CreateEventChecker doesn't understand the event type '" + eventInfo.Type + "'."
                        );
            }
        }
    }
}
